package com.yunji.generate.bean;

import com.yunji.generate.util.StringUtil;

import java.io.Serializable;

/**
 * 字段信息
 *
 * @author hushuang
 * @since 2019/9/20
 */
public class FieldInfo implements Serializable {

    /**
     * 是否主键
     */
    private boolean isPrimary;

    /**
     * Java 类名
     */
    private String className;

    /**
     * 属性名称
     */
    private String name;

    ///////

    /**
     * 数据类型名称，比如 VARCHAR
     */
    private String typeName;

    /**
     * 数据类型
     */
    private Integer dataType;

    /**
     * 小数位数
     */
    private Integer decimalDigits;

    /**
     * 列长度
     */
    private Integer columnSize;

    /**
     * 列备注
     */
    private String remarks;

    /**
     * 获取类名(freemarker)
     */
    public String getClassSimpleName() {
        return className.substring(className.lastIndexOf('.') + 1);
    }

    /**
     * 获取截短后的备注(freemarker)
     */
    public String getShortRemarks() {
        return StringUtil.truncateRemarks(remarks);
    }

    /**
     * 获取枚举表达式(freemarker)
     */
    public String getEnumExpre() {
        return StringUtil.truncateEnumExpre(remarks);
    }

    public boolean isPrimary() {
        return isPrimary;
    }

    public void setPrimary(boolean primary) {
        isPrimary = primary;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Integer getDataType() {
        return dataType;
    }

    public void setDataType(Integer dataType) {
        this.dataType = dataType;
    }

    public Integer getDecimalDigits() {
        return decimalDigits;
    }

    public void setDecimalDigits(Integer decimalDigits) {
        this.decimalDigits = decimalDigits;
    }

    public Integer getColumnSize() {
        return columnSize;
    }

    public void setColumnSize(Integer columnSize) {
        this.columnSize = columnSize;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
